<?php
/**
 * Created by PhpStorm.
 * User: qhzhyt
 * Date: 2018/10/15
 * Time: 15:45
 */

if (!isset($_GET['offset'])) {
    $offset = 0;
} else {
    $offset = intval($_GET['offset']);
}

if (!isset($_GET['count'])) {
    $count = 20;
} else {
    $count = intval($_GET['count']);
}

session_start();

if (!isset($_SESSION['user'])) {
    echo(json_encode(['status' => 0, 'code' => -1]));
    exit(1);
}
require_once '../conf/conf.php';
$user = $_SESSION['user'];


$collectionList = $db->select('map', ['[><]collection' => 'map_id'],
    ['collection.user_id(self_id)', 'map.user_id', 'map_id', 'map_name', 'map_hash', 'upload_time', 'challenge_count', 'challenge_count', 'pass_count', 'collect_count', 'collect_time', '"comment_count"'],
    ['collection.user_id' => $user['user_id'], 'ORDER' => ['collect_time' => 'DESC'], 'LIMIT' => [$offset, $count]]);

echo json_encode(['status' => 1, 'code' => 1, 'data' => $collectionList]);
